package com.liesheng.haylou.ui.personal;

import android.animation.ValueAnimator;
import android.content.Intent;
import android.view.View;
import android.widget.ProgressBar;

import com.liesheng.haylou.R;
import com.liesheng.haylou.base.BaseActivity;
import com.liesheng.haylou.base.BaseFunActivity;
import com.liesheng.haylou.base.BaseVm;
import com.liesheng.haylou.databinding.ActivitySportDataBinding;


import androidx.databinding.DataBindingUtil;

/**
 * Created by Android Studio.
 * User: zhangzhiqiang
 * Date: 2019/12/20
 * Time: 15:13
 */
public class SportDataActivity extends BaseActivity<ActivitySportDataBinding, BaseVm> {
    @Override
    protected ActivitySportDataBinding getmBinding() {
        mBinding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.activity_sport_data, null, false);
        //隐藏掉整个ActionBar
        return mBinding;
    }

    @Override
    protected BaseVm getViewModel() {
        return null;
    }

    @Override
    protected void initData() {
        setTitle("身体数据");
        setAnimation(mBinding.bpNum, 80);
        setAnimation(mBinding.pbhoist,50);
        setAnimation(mBinding.pbWeight,50);
    }

    public static void startBy(BaseFunActivity activity) {
        Intent intent = new Intent(activity, SportDataActivity.class);
        activity.startActivity(intent);
    }

    @Override
    public void onClickView(View view) {
        switch (view.getId()) {
            case R.id.progressBar:
                break;

        }
    }
    private void setAnimation(final ProgressBar view, final int mProgressBar) {
        ValueAnimator animator = ValueAnimator.ofInt(0, mProgressBar).setDuration(5000);

        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                view.setProgress((int) valueAnimator.getAnimatedValue());
            }
        });
        animator.start();
    }

}
